<!-- stories/templates/stories/admin_dashboard.html -->
{% extends 'stories/base.html' %}
{% load static %}

{% block title %}管理员数据统计 - AI故事生成网站{% endblock %}

{% block content %}
<div class="container">
    <div class="page-header">
        <h1>管理员数据统计</h1>
        <div class="page-actions">
            <a href="{% url 'stories:admin_review' %}" class="btn btn-secondary">返回审核中心</a>
        </div>
    </div>

    <!-- 数据统计卡片 -->
    <div class="dashboard-stats">
        <div class="stat-card">
            <div class="stat-icon">📝</div>
            <div class="stat-info">
                <div class="stat-number">{{ total_stories }}</div>
                <div class="stat-label">总故事数</div>
            </div>
        </div>
        
        <div class="stat-card">
            <div class="stat-icon">✅</div>
            <div class="stat-info">
                <div class="stat-number">{{ published_stories }}</div>
                <div class="stat-label">已发布</div>
            </div>
        </div>
        
        <div class="stat-card">
            <div class="stat-icon">⏳</div>
            <div class="stat-info">
                <div class="stat-number">{{ pending_stories }}</div>
                <div class="stat-label">待审核</div>
            </div>
        </div>
        
        <div class="stat-card">
            <div class="stat-icon">💾</div>
            <div class="stat-info">
                <div class="stat-number">{{ draft_stories }}</div>
                <div class="stat-label">草稿</div>
            </div>
        </div>
        
        <div class="stat-card">
            <div class="stat-icon">❌</div>
            <div class="stat-info">
                <div class="stat-number">{{ rejected_stories }}</div>
                <div class="stat-label">已驳回</div>
            </div>
        </div>
        
        <div class="stat-card">
            <div class="stat-icon">👥</div>
            <div class="stat-info">
                <div class="stat-number">{{ total_users }}</div>
                <div class="stat-label">总用户数</div>
            </div>
        </div>
        
        <div class="stat-card">
            <div class="stat-icon">💬</div>
            <div class="stat-info">
                <div class="stat-number">{{ total_comments }}</div>
                <div class="stat-label">总评论数</div>
            </div>
        </div>
        
        <div class="stat-card">
            <div class="stat-icon">⭐</div>
            <div class="stat-info">
                <div class="stat-number">{{ total_ratings }}</div>
                <div class="stat-label">总评分</div>
            </div>
        </div>
    </div>

    <!-- 最近故事列表 -->
    <div class="recent-stories">
        <h2>最近故事</h2>
        {% if recent_stories %}
            <div class="stories-table">
                <table>
                    <thead>
                        <tr>
                            <th>标题</th>
                            <th>作者</th>
                            <th>分类</th>
                            <th>状态</th>
                            <th>创建时间</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for story in recent_stories %}
                            <tr>
                                <td>
                                    <a href="{% url 'stories:review_story' story.id %}">{{ story.title }}</a>
                                </td>
                                <td>{{ story.author.username }}</td>
                                <td>{{ story.category.name }}</td>
                                <td>
                                    {% if story.status == 'pending' %}
                                        <span class="status-pending">待审核</span>
                                    {% elif story.status == 'published' %}
                                        <span class="status-published">已发布</span>
                                    {% elif story.status == 'draft' %}
                                        <span class="status-draft">草稿</span>
                                    {% elif story.status == 'rejected' %}
                                        <span class="status-rejected">已驳回</span>
                                    {% endif %}
                                </td>
                                <td>{{ story.created_at|date:"Y-m-d H:i" }}</td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        {% else %}
            <div class="no-stories">
                <p>暂无故事</p>
            </div>
        {% endif %}
    </div>
</div>
{% endblock %}